<template>
  <div class="facility_manage">
    <van-nav-bar title="设施管理" left-arrow @click-left="onClickLeft" fixed />
    <ul class="manage_content">
      <li>
        <div class="content_key">所属种类</div>
        <div class="content_text">{{ object.categoryName }}</div>
      </li>
      <li>
        <div class="content_key">设备名称</div>
        <div class="content_text">{{ object.name }}</div>
      </li>
      <li>
        <div class="content_key">所在位置</div>
        <div class="content_text">{{ object.position }}</div>
      </li>
      <li>
        <div class="content_key">设备介绍</div>
        <div class="content_text">{{ object.description }}</div>
      </li>
      <li>
        <div class="content_key">负责人</div>
        <div class="content_text">{{ object.principal }}</div>
      </li>
      <li>
        <div class="content_key">责任人电话</div>
        <div class="content_text">{{ object.phone }}</div>
      </li>
    </ul>
    <div class="devide_div"></div>
    <div class="manage_content" style="padding-bottom:30px;">
      <span>设备图片</span>
      <img
        v-for="(item, index) in imgList"
        :key="index"
        v-lazy="item"
        @click="imgPreview(index)"
      />
    </div>
    <div class="devide_div"></div>
    <div class="manage_content" style="padding-bottom:40px;">
      <span>设备质量合格证</span>
      <img
        v-for="(item, index) in certificateList"
        :key="index"
        v-lazy="item"
        @click="imgPreviewCer(index)"
      />
    </div>
    <!-- <div class="btn_group">
      <div class="left_btn" @click="contact()">
        <svg-icon icon-class="形状"></svg-icon>
        <span style="margin-left:14px;">联系他</span>
      </div>
      <div class="right_btn" @click="repair(object)">
        <span>报修</span>
      </div>
    </div> -->
    <div class="contact_btn" style="padding:10px 0;">
      <a :href="`tel:${object.phone}`" style="color:#ffffff;">联系他</a>
    </div>
  </div>
</template>

<script>
import { ImagePreview } from "vant";
import api from "@/controller/smartProperty.js";
import constant from "@/controller/constant.js";
export default {
  name: "facilityManage",
  data() {
    return {
      object: {},
      imgList: [],
      certificateList: [],
    };
  },
  mounted() {
    this.getFacilityDetail(this.$route.query.id)
  },
  methods: {
    getFacilityDetail(id) {
      api.community_community_facility_id(id).then(res => {
        if (res.code === "0") {
          this.object = res.datas
          this.imgList = res.datas.images.split(',')
          this.certificateList = res.datas.certificate.split(',')
        } else {
          if (res && res.msg) {
            this.$toast(res.msg);
          } else {
            this.$toast(constant.unusualMsg);
          }
        }
      })
    },
    onClickLeft() {
      this.$router.go(-1);
    },
    imgPreview(val) {
      ImagePreview({
        images: this.imgList,
        startPosition: val
      });
    },
    imgPreviewCer(val) {
      ImagePreview({
        images: this.certificateList,
        startPosition: val
      });
    },
    contact() {
      this.$toast("联系他");
    }
    // repair(item) {
    //   this.$router.push({
    //     name: 'facilityRepair',
    //     query: {
    //       val: item
    //     }
    //   })
    // }
  }
};
</script>

<style lang="scss" scoped>
@import "../styles/workstation.scss";
.facility_manage {
  height: 100%;
  background: #ffffff;
  // padding-bottom: 54px;

  // .btn_group {
  //   display: flex;
  //   flex-wrap: wrap;
  //   width: 100%;
  //   height: 44px;
  //   background: #ffffff;
  //   text-align: center;
  //   font-size: 15px;
  //   position: fixed;
  //   bottom: 0;
  //   z-index: 1;

  //   .left_btn {
  //     padding: 12px 0 11px 0;
  //     width: 50%;
  //     color: #DC4630;

  //     span {
  //       line-height: 21px;
  //     }
  //   }

  //   .right_btn {
  //     padding: 12px 0 11px 0;
  //     width: 50%;
  //     background: #DC4630;
  //     color: #ffffff;

  //     span {
  //       line-height: 21px;
  //     }
  //   }
  // }

  .contact_btn {
    width: 345px;
    margin: 15px;
    border-radius: 22px;
    background: #dc4630;
    color: #ffffff;
    text-align: center;
    font-size: 16px;
  }

  .manage_content {
    display: flex;
    flex-wrap: wrap;
    padding: 0 15px;
    background: #ffffff;

    span {
      font-size: 14px;
      color: #333333;
      line-height: 20px;
      padding: 14.5px 0 10px 0;
      width: 100%;
    }

    img {
      border-radius: 4.25px;
      width: 2.9333rem;
      height: 2.2rem;
    }

    img:nth-child(3n + 1) {
      margin-left: 7.5px;
    }

    img:nth-child(3n + 3) {
      margin-left: 7.5px;
    }

    img:nth-child(n + 5) {
      margin-top: 7.5px;
    }

    li {
      padding: 14.5px 0;
      width: 100%;
      border-bottom: 1px solid #edeff2;
      font-size: 14px;
      color: #333333;
      line-height: 20px;
    }

    li:first-child {
      padding-top: 20px;
    }
    li:last-child {
      border: none;
    }

    .content_key {
      width: 106px;
      float: left;
    }

    .content_text {
      width: 239px;
      float: right;
      text-align: right;
    }
  }
}
</style>
